package com.javabasic.proxy.static_proxy;

/**
 * @Author xiongmin
 * @Description //TODO
 * @Date 2020/5/31 21:50
 * @Version 1.0
 **/
public class CustomTestStaticProxy implements SayInterface {

    private SayInterface sayInterface;

    public CustomTestStaticProxy(SayInterface sayInterface) {
        this.sayInterface = sayInterface;
    }

    @Override
    public void sayHello() {
        preLog();
        this.sayInterface.sayHello();
        postLog();
    }

    @Override
    public void saySomething(String something) {
        preLog();
        this.sayInterface.saySomething(something);
        postLog();
    }

    @Override
    public String saySomethingWithResult(String something) {
        preLog();
        String result = this.sayInterface.saySomethingWithResult(something);
        postLog();
        return result;
    }

    private void preLog() {
        System.out.println("=========开始执行=========");
    }

    private void postLog() {
        System.out.println("=========结束执行=========");
    }

}
